package com.hpjpw.ido.controller;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hpjpw.ido.domain.AnonymousMoment;
import com.hpjpw.ido.service.IAnonymousMomentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 撕逼墙Controller
 * 
 * @author hpj
 * @date 2021-01-05
 */
//@Api(value ="AnonymousMomentController")
@RestController
@RequestMapping("/ido/anonymous_moment")
public class AnonymousMomentController extends BaseController
{
    @Autowired
    private IAnonymousMomentService anonymousMomentService;

    /**
     * 查询撕逼墙列表
     */
    @PreAuthorize("@ss.hasPermi('ido:anonymous_moment:list')")
    @GetMapping("/list")
    //@ApiOperation("查询撕逼墙列表")
    public TableDataInfo list(AnonymousMoment anonymousMoment)
    {
        startPage();
        List<AnonymousMoment> list = anonymousMomentService.selectAnonymousMomentList(anonymousMoment);
        return getDataTable(list);
    }

    /**
     * 导出撕逼墙列表
     */
    @PreAuthorize("@ss.hasPermi('ido:anonymous_moment:export')")
    @Log(title = "撕逼墙", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    //@ApiOperation("导出撕逼墙列表")
    public AjaxResult export(AnonymousMoment anonymousMoment)
    {
        List<AnonymousMoment> list = anonymousMomentService.selectAnonymousMomentList(anonymousMoment);
        ExcelUtil<AnonymousMoment> util = new ExcelUtil<AnonymousMoment>(AnonymousMoment.class);
        return util.exportExcel(list, "anonymous_moment");
    }

    /**
     * 获取撕逼墙详细信息
     */
    @PreAuthorize("@ss.hasPermi('ido:anonymous_moment:query')")
    @GetMapping(value = "/{id}")
    //@ApiOperation("获取撕逼墙详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(anonymousMomentService.selectAnonymousMomentById(id));
    }

    /**
     * 新增撕逼墙
     */
    @PreAuthorize("@ss.hasPermi('ido:anonymous_moment:add')")
    @Log(title = "撕逼墙", businessType = BusinessType.INSERT)
    @PostMapping
    //@ApiOperation("新增撕逼墙")
    public AjaxResult add(@RequestBody AnonymousMoment anonymousMoment)
    {
        return toAjax(anonymousMomentService.insertAnonymousMoment(anonymousMoment));
    }

    /**
     * 修改撕逼墙
     */
    @PreAuthorize("@ss.hasPermi('ido:anonymous_moment:edit')")
    @Log(title = "撕逼墙", businessType = BusinessType.UPDATE)
    @PutMapping
    //@ApiOperation("修改撕逼墙")
    public AjaxResult edit(@RequestBody AnonymousMoment anonymousMoment)
    {
        return toAjax(anonymousMomentService.updateAnonymousMoment(anonymousMoment));
    }

    /**
     * 删除撕逼墙
     */
    @PreAuthorize("@ss.hasPermi('ido:anonymous_moment:remove')")
    @Log(title = "撕逼墙", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    //@ApiOperation("删除撕逼墙")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(anonymousMomentService.deleteAnonymousMomentByIds(ids));
    }
}
